public class Leetcode357 {
    public static void main(String[] args) {
        System.out.println(countNumbersWithUniqueDigits(3));
    }

    public static int countNumbersWithUniqueDigits(int n) {
        if (n == 0) {
            return 1;
        }

        int res = 9;
        for (int i = 1; i < n; i++) {
            res *= (10 - i);
        }

        return countNumbersWithUniqueDigits(n - 1) + res;
    }

}
